<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--
    插槽（slot）:留出不确定的标签
    在Vue.js中我们使用 元素作为承载分发内容的出口，
    作者称其为插槽，可以应用在组合组件的场景中;

    slot="todo-title"
    slot="todo-li"
    定义slot组件中得绑定对应组件名称，使用的时候也得绑定
  -->
<div id="app">
    <todo>
        <todo-title slot="todo-title" v-bind:title="title"></todo-title>
        <todo-li slot="todo-li" v-for="item in todoItems" v-bind:item="item"></todo-li>
    </todo>
</div>

<!--导入vue.js-->
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
<script>

    Vue.component("todo",{
        template: "<div>\n" +
        "        <slot name='todo-title'></slot>\n" +
        "        <ul>\n" +
        "            <slot name='todo-li'></slot>\n" +
        "        </ul>\n" +
        "    </div>"
    })

    //标题
    Vue.component("todo-title",{
        props:['title'],
        template: "<p>{{title}}</p>"
    })

    //列表，数据
    Vue.component("todo-li",{
        props:['item'],
        template: "<li>{{item}}</li>"
    })


    var vm = new Vue({
        el: "#app",
        data:{
            title: "狂神说",
            todoItems: ["MyBatis","Spring","SpringMvc"]
        }
    })
</script>
</body>
</html>